home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / rjs.lha / RJS / CmdLine / src / CmdOpt_int_range.C < prev    next >
C/C++ Source or Header  |  1991-06-14  |  2KB  |  75 lines

  1. #include "CmdLine.h"
  2.  
  3. #include <RJS/Convert.h>
  4.  
  5. void RJS_CmdOpt_int_range::reset()
  6. {
  7.     lval=0; 
  8.     hval=0;
  9.     l_present=RJS_CmdOpt::NotPresent;
  10.     h_present=RJS_CmdOpt::NotPresent;
  11.     RJS_CmdOpt::reset();
  12. }
  13.  
  14. RJS_CmdOpt_int_range::RJS_CmdOpt_int_range(const char *k, RJS_CmdOpt::CmdOptFlags f) 
  15.     : RJS_CmdOpt(k,f|Value) 
  16.     lval=0; 
  17.     hval=0;
  18.     l_present=RJS_CmdOpt::NotPresent;
  19.     h_present=RJS_CmdOpt::NotPresent;
  20. }
  21.  
  22. RJS_CmdOpt_int_range::RJS_CmdOpt_int_range(const char *k, const RJS_String &df,
  23.         RJS_CmdOpt::CmdOptFlags f) : RJS_CmdOpt(k,df,f)
  24.     lval=0; 
  25.     hval=0;
  26.     l_present=RJS_CmdOpt::NotPresent;
  27.     h_present=RJS_CmdOpt::NotPresent;
  28. }
  29.  
  30. int RJS_CmdOpt_int_range::set_value() 
  31. {
  32.     RJS_String low,high;
  33.     l_present=RJS_CmdOpt::NotPresent;
  34.     h_present=RJS_CmdOpt::NotPresent;
  35.     
  36.     if (RJS_CmdOpt::val.contains(':')) {
  37.         low=RJS_CmdOpt::val.before(':');
  38.         high=RJS_CmdOpt::val.after(':');
  39.     } else {
  40.         low=RJS_CmdOpt::val;
  41.         high="";
  42.     }
  43.  
  44.     if (low.length()) {
  45.         lval=RJS_Convert::toInt(low);
  46.         if (!RJS_Convert::ok()) return 0; 
  47.         l_present=RJS_CmdOpt::Present;
  48.     }
  49.  
  50.     if (high.length()) {
  51.         hval=RJS_Convert::toInt(high);
  52.         if (!RJS_Convert::ok()) return 0;
  53.         h_present=RJS_CmdOpt::Present;
  54.     } 
  55.     return 1;
  56. }
  57.  
  58. const char *RJS_CmdOpt_int_range::value_type()
  59. {
  60.     return "integer range";
  61. }
  62.  
  63.  
  64. void RJS_CmdOpt_int_range::dump()
  65. {
  66.     RJS_CmdOpt::dump();
  67.     cout << "int_range: low range ";
  68.     if (low_is_present()) cout << low_value(); else cout << "?";
  69.     cout << " high range ";
  70.     if (high_is_present()) cout << high_value(); else cout << "?";
  71.     cout << endl;
  72. }
  73.